package com.zj.service.yb;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zj.common.TiripPackage;
import com.zj.common.mq.SendMessage;
import com.zj.common.mq.SsReciveMessage;

/**
 * 
 * @author lu 个人缴费划转结算行总额对账请求
 * 
 */
@Service
public class JhSyJshDz {
	private static final Logger logger = LoggerFactory.getLogger(JhSyJshDz.class);
	@Autowired
	SendMessage sendMessage;

	@Autowired
	SsReciveMessage ssReciveMessage;

	@SuppressWarnings("unchecked")
	public void pk(String crId, TiripPackage tiripPackage) throws Exception {
//		 解析字段存储数据库
//		String content = XmlUtil.subCdata(tiripPackage);
//		logger.info("接受批扣请求" + content);
//		PkBody request = XmlUtil.toBean(XmlUtil.subCdata(tiripPackage), PkBody.class);
//
//		// 发送总行,商业银行收到批扣缴费请求后，返回税银子系统收妥响应
//		tiripPackage.getIdentity().setServiceId("SYPKA2");
//		// 异步返回给税务局已收到
//		tiripPackage.setBusinessContent(null);
//		ReturnState returnState = new ReturnState("000", "成功");
//		sendMessage.sendYb(crId, XmlUtil.toXml(tiripPackage, "GBK"));
//		List<Spmx> list = new ArrayList<>();
//		for (SpmxList spmxList : request.getBody()) {
//			com.zj.request.body.Spmx spmx = spmxList.getSpmx();
//			Spmx spmxResp = new com.zj.response.body.Spmx(spmx.getXtsphm(), spmx.getSwjylsh(), spmx.getKprq(),
//					spmx.getKpje(), new ReturnInfo("000", "成功"));
//			list.add(spmxResp);
//		}
//		JhSyPkRespBody jhSyPkRespBody = new JhSyPkRespBody(list);
//		OpenRequest<JhSyPkReqHead, JhSyPkRespBody> resp = new OpenRequest<>();
//		resp.setCnName("个人税务批扣缴费结果回执响应（对外）");
//		resp.setName("jhSyPKResponse");
//		resp.setHead(request.getHead());
//		resp.setBody(jhSyPkRespBody);
//		tiripPackage.setBusinessContent(new BusinessContent(new SubPackage(XmlUtil.toXmlNoHead(resp))));
//		String xml = XmlUtil.toXml(tiripPackage, "GBK");
//		sendMessage.sendYb(crId, xml);
//		logger.info("返回批扣请求" + xml);

		// 扣款成功

	}

}
